/**
 * 
 */
package com.mvc.service.healthmanager.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.mvc.dao.BaseDaoI;
import com.mvc.dao.mapper.BloodDietDao;
import com.mvc.model.base.BloodDietData;
import com.mvc.model.base.powerSource;
import com.mvc.model.healthmanager.archive.BloodDiet;
import com.mvc.model.personHealth.ActivityAndDiet;
import com.mvc.service.healthmanager.BloodDietServiceI;

/**
 * @author Roy
 *
 */
@Service
public class BloodDietSerivceImpl implements BloodDietServiceI{
	@Autowired
	private BaseDaoI<powerSource> psDaoI;
	@Autowired
	private BaseDaoI<BloodDiet> bDaoI;
	@Autowired
	private BloodDietDao bdDao;
	@Autowired
	private BaseDaoI<ActivityAndDiet> baseDaoD;
	
	
	@Override
	public BloodDietData findBloodDiets(String personId, int sizes) {
//		List<powerSource> list = bdDao.findpowerSource(personId);
		List<ActivityAndDiet> li = baseDaoD.find("from ActivityAndDiet where personId='"+personId+"' order by id desc");
		BloodDietData bdd = new BloodDietData();
		if(li.size()>sizes){
			BeanUtils.copyProperties(JSON.parseObject(li.get(sizes).getPowerSource(), powerSource.class), bdd);
		}
		return bdd;
		
		
	}

}
